package com.victor9ac.tfm.flickr.client;



import com.flickr4java.flickr.Flickr;
import com.flickr4java.flickr.FlickrException;
import com.flickr4java.flickr.photos.Photo;
import com.flickr4java.flickr.photos.PhotoList;
import com.flickr4java.flickr.photos.SearchParameters;

public class FlickrClient {



	FlickrConnector flickrConnector;

	public FlickrClient() {
		
	}
	
	public FlickrClient(FlickrConnector flickrConnector) {
		this.flickrConnector = flickrConnector;
	}

	public PhotoList<Photo> getPhotos(String keyword) throws FlickrException{
		
		Flickr f = flickrConnector.getFlickrInstance();
		
		 //initialize SearchParameter object, this object stores the search keyword
	    SearchParameters searchParams=new SearchParameters();
	    searchParams.setSort(SearchParameters.INTERESTINGNESS_DESC);
		
	    //Create tag keyword array
	    String[] tags=new String[]{keyword};
	    searchParams.setTags(tags);
		
	    PhotoList<Photo> photoList = f.getPhotosInterface().search(searchParams, 20, 1);
	    
	    return photoList;
	}
	
	
	public void setFlickrConnector(FlickrConnector flickrConnector) {
		this.flickrConnector = flickrConnector;
	}
}
